package com.hfb.mashibing.alip8.system.io;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.util.LinkedList;

public class T03_C10Kclient {

    public static void main(String[] args) throws IOException {
        LinkedList<SocketChannel> clients = new LinkedList<>();
        InetSocketAddress serverAddr = new InetSocketAddress("127.0.0.1",9090);

        for (int i = 10000; i < 65000; i++) {
            SocketChannel client1 = SocketChannel.open();
            client1.bind(new InetSocketAddress("127.0.0.1", i));
            client1.connect(serverAddr);
            Boolean c1 = client1.isOpen();
            clients.add(client1);

            SocketChannel client2 = SocketChannel.open();
            client2.bind(new InetSocketAddress("127.0.0.100", i));
            client2.connect(serverAddr);
            Boolean c2 = client2.isOpen();
            clients.add(client2);

        }
        System.out.println("clients length: " + clients.size());



    }

}
